home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Collections: MegaDisc
/
MegaDisc 41 (1994-09)(MegaDisc Digital Publishing)(AU)(Disk 2 of 2).zip
/
MegaDisc 41 (1994-09)(MegaDisc Digital Publishing)(AU)(Disk 2 of 2).adf
/
ARexx_&_HBook
/
Quarl
/
QUARL.rexx
< prev
Wrap
OS/2 REXX Batch file
|
1994-08-31
|
32KB
|
819 lines
/* */
/* Quick ARexx Lookup - An ARexx Utility */
/* By John Collett September 1994 */
/* Set your tab size to 4 for a comfortable read of this script */
signal on syntax ; signal on error
if ~show('l','rexxarplib.library') then do
check = addlib('rexxsupport.library',0,-30,0)
check = addlib('rexxarplib.library',0,-30,0)
end
address AREXX '"call CreateHost(HO, PORT)"'
if ~show('Ports',HO) then address command 'WaitForPort HO'
call SetReqColor(HO,SHADOWPEN,0) ; call SetReqColor(HO,BOXPEN,2)
w = 300 ; h = 178
flags = 'WINDOWCLOSE+WINDOWDRAG+WINDOWDEPTH'
idcmp = 'CLOSEWINDOW+GADGETUP'
call OpenWindow(HO,140,1,w,h,idcmp, flags,"Quick ARexx Lookup")
call openport(PORT) ; call ActivateWindow(HO)
/* Column 1 */
str = "Flow of Control;Functions and Args;Strings 1;Strings 2;" ||,
"Numbers;Operators;Bit manipulation;Data conversion;"||,
"Values and Variables;Console Input/Output;Files;Script Environment;"||,
"ARexx Environment;Messages and Ports;Operating System"
max = 20 ; left = 20 ; call BuildColumn(1)
/* Fiddle with this program as much as you like, but if you alter the
entries beyond line 170, these increment settings will no longer be
correct, and will have to be adjusted for the program to work. */
Inc.1 = 0 ; Inc.2 = 43 ; Inc.3 = 62 ; Inc.4 = 132 ; Inc.5 = 206
Inc.6 = 249 ; Inc.7 = 300 ; Inc.8 = 337 ; Inc.9 = 365 ; Inc.10 = 391
Inc.11 = 414 ; Inc.12 = 470 ; Inc.13 = 519 ; Inc.14 = 556 ; Inc.15 = 579
/* Find start points beyond current minimum */
last = sourceline() ; n = 170
do forever
n = n + 1 ; if sourceline(n) = '<1' then leave
end
do s = 1 to 15 ; start.s = n + Inc.s ; end
/* Wait for user selection */
do forever
call waitpkt(PORT) ; p = getpkt(PORT)
if p ~== NULL() then do
i = getarg(p)
t = reply(p, 0)
parse var i class gadno x y .
select
when class = 'CLOSEWINDOW' then signal 'Finish'
when class = 'GADGETUP' then do
req = PostMsg()
if gadno < 16 then call Gadget1() ; else call Gadget2()
end
otherwise
end /* of 'select' */
end /* of 'if ... then do' */
end /* of 'do forever' */
Finish:
req = PostMsg()
call CloseWindow(HO)
exit
syntax: say 'Syntax : ' errortext(rc) '. Line 'sigl ; signal 'Finish'
error: say "Error " rc sigl ; signal 'Finish'
Gadget1:
if ngads > 15 then do
do g = 16 to ngads ; call RemoveGadget(HO,g) ; end
call APen(0) ; call RectFill(HO,186,12,w-6,h-4)
end
left = 200 ; call msg(2)
select
when gadno = 1 then do
str = "break;do;else;end;exit;if;interpret;iterate;leave;nop;",
|| "otherwise;select;signal;then;when" ; max = 9
end
when gadno = 2 then do
str = "arg;arg();call;procedure;return" ; max = 9
end
when gadno = 3 then do
str = "compress;delstr;insert;overlay;strip;substr;translate;",
|| "trim;upper;abbrev;compare;index;lastpos;pos;verify;center;"
max = 9
end
when gadno = 4 then do
str = "left;reverse;right;space;delword;find;subword;word;",
|| "wordindex;wordlength;words;copies;hash;length;parse;xrange"
max=10 ; end
when gadno = 5 then do
str ="abs;digits;form;fuzz;max;min;numeric;random;randu;sign;trunc"
max = 7 ; end
when gadno = 6 then do
str ="~;+ -;** *;/ % //;||;== ~==;= ~=;> >= ~<;< <= ~>;& |;^ &&"
max = 7 ; end
when gadno = 7 then do
str ="bitand;bitchg;bitclr;bitcomp;bitor;bitset;bittst;bitxor"
max = 7 ; end
when gadno = 8 then do
str ="b2c;c2b;c2d;c2x;d2c;d2x;x2c;x2d" ; max = 3 ; end
when gadno = 9 then do
str ="datatype;drop;symbol;value" ; max = 8 ; end
when gadno = 10 then do
str ="echo;lines;pull;push;queue;say" ; max = 5 ; end
when gadno = 11 then do
str ="close;eof;open;readch;readln;seek;writech;writeln;",
|| "delete;exists;makedir;rename;showdir;statef" ; max = 7 ; end
when gadno = 12 then do
str ="date;errortext;options;sourceline;time;trace;trace()"
max = 10 ; end
when gadno = 13 then do
str ="addlib;address;address();freespace;getclip;getspace;remlib;",
|| "setclip;shell;show" ; max = 9 ; end
when gadno = 14 then do
str ="closeport;getarg;getpkt;openport;reply;typepkt;waitpkt"
max = 9 ; end
when gadno = 15 then do
str ="allocmem;baddr;delay;export;forbid;freemem;import;",
|| "next;null;offset;permit;pragma;showlist;storage" ; max = 8
end
otherwise
end
activeset = gadno ; call BuildColumn(16) ; call LoadList()
call APen(3) ; call RectFill(HO,186,gadno*10+4,192,gadno*10 +12)
call msg(0)
return
msg: call APen(arg(1)) ; call Move(HO,80,172) ; call Text(HO,"Loading")
return
LoadList:
/* Get starting lines for current set of column 2 gadgets */
start = start.activeset ; n_in_set = ngads - 15
start.activeset.1 = start ; n = 0
do s = 2 to n_in_set
do forever
n = n + 1 ; if sourceline(start+n) = '' then leave
end
start.activeset.s = start + n
end
return
Gadget2:
rank = gadno-15 ; lef = 212+max*8
/*call APen(0) ; call RectFill(HO,lef,12,w-6,h-12) ; call APen(1)*/
line_num = start.activeset.rank ; j = 0 ; msg = ''
/* Get the lines for this commentary */
do forever
j = j + 1 ; thisl = line_num + j ; line = sourceline(thisl)
if strip(line) = '' then leave
msg = msg || line
end
longest = 0 ; n = 0 ; f = 1
do forever
/* Dissect the message for '\'s, to know how deep the message box
will be, to help determine its position */
n = n + 1 ; s = index(msg,'\',f)
if s > 0 then longest = max(longest,s-f)
else do ; longest = max(longest,length(msg)-f) ; leave ; end
f = s + 1
end
if n < 4 then y = h+10 ; else y = 230 - n*10
longest = max(longest,24) ; x = 270 - longest*4
req = PostMsg(x,y,msg)
return
BuildColumn: /* of clickable gadgets */
do i = 1 until str = ''
parse var str a ';' str ; a = a || copies(' ',max-length(a))
call AddGadget(HO,left,4+10*i,arg(1)+i-1,a,'%l %d')
end
ngads = arg(1)+i-1 ; x = max*8 + 4 ; y = 3+10*(i+1)
call APen(2) ; call Move(HO,left,y)
call Draw(HO,left+x,y) ; call Draw(HO,left+x,14)
call APen(0) ; call Move(HO,left-2,y+1) ; call Draw(HO,left,y+1)
return
APen: call SetAPen(HO,arg(1)) ; return
/*
<1
BREAK\Exit from innermost DO-END block\or INTERPRET instruction
DO\Begin a block of instructions or a loop\DO FOREVER\DO [FOR] count\
DO WHILE/UNTIL test\DO var=start [TO limit] [BY step]\
DO [FOR] count WHILE/UNTIL test\
DO var=start [TO limit] [BY step] FOR count\
Do var=start [TO limit] [BY step] WHILE/UNTIL test\
DO var=start [TO limit] [BY step] FOR count WHILE/UNTIL test
ELSE\Introduce code to be executed\when an IF test fails\ELSE [;] instruction
END [var]\Terminate a block of instructions\beginning with DO or SELECT
EXIT [expr]\Terminate a script
IF\Introduce code to be executed\if test expression is True\
IF test [;]\ THEN [;] instruction\ [ELSE [;] instruction]
INTERPRET [expr]\Execute ARexx instructions\contained in a string
ITERATE [var]\Skip to the end of the\current iterative loop
LEAVE [var]\Break out of current iterative loop
NOP\Do nothing - a dummy instruction
OTHERWISE\Introduce default case\for SELECT control structure\
OTHERWISE [;] [instruction(s)]
SELECT\Branch to first case whose\controlling condition is met\
SELECT\ WHEN ...\ [OTHERWISE [;] [instructions]]\ END
SIGNAL\Trap for various kinds of errors as required,\
or to transfer control to a label (like a GO TO!)\
SIGNAL ON type\ SIGNAL OFF type\ SIGNAL [VALUE] label-expression
THEN\Execute dependent instruction\if preceding expression was True\
THEN [;] instruction
WHEN\In SELECT, introduce code to be\executed if test is True\
WHEN test [;] THEN [;] instruction
<2
ARG [template] [,template ...]\Shorthand form of PARSE UPPER ARG\
Used to split input strings into substrings.
ARG()\Return information about function arguments;\
how many there are, what each one is...\
numargs = ARG()\ argn = ARG(num)\ bool = ARG(num, mode)\
Modes: E - Exists O - Omitted
CALL function arg, arg, arg\or CALL function(arg, arg, arg)\
To invoke a function when what it DOES is its\
purpose, and a returned RESULT is not required.
PROCEDURE [EXPOSE var [var ...]]\
Protect variables within a function\call from name collisions,\
but allow sharing (EXPOSE) of any\which need to be passed in or out.
RETURN [expr]\Return control (and\optionally a value) to caller
<3
COMPRESS\s = COMPRESS(str, [list])\
Remove the characters in list (default=space) from str\
compress("writhing","rg") -> within
DELSTR\s = DELSTR(str, start, [len])\
Delete len (default=rest of str) characters\
from str, from start\ delstr("writhing",2,4) -> wing
INSERT\s = insert(istr,str,[start],[len],[pad])\
Insert len characters of istr into str at start\
insert("inky","thing",2,3) -> thinking
OVERLAY\s = OVERLAY(new, old, [start], [len], [pad])\
Overlay len characters of new on old, from start\
overlay("irrational","invitation",1,3) -> irritation
STRIP\s = STRIP(str, [mode], [list])\
Strip leading and/or trailing characters in list from str\
Modes: B - Both (default) L - Leading T - Trailing\
strip("slaughters","b","s") -> laughter
SUBSTR\s = SUBSTR(str, start, [len],[pad])\
Extract len (default=rest of str)\characters of str, from start\
substr("Jericho",3,4) -> rich
TRANSLATE\s = TRANSLATE(str)\s = TRANSLATE(str,[output],[input],[pad])\
Translate str using input and output character tables\
translate("abracadabra",xrange("1","4"),xrange("a","d")\ -> 12r131412r1
TRIM\s = TRIM(str)\Remove trailing blanks from str\
str1 = "abcde " length(str1) is 10\
str2 = trim(str1) -> abcde length(str2) is 5
UPPER var [var ...]\Convert contents of variables to upper case\
s = UPPER(str)\Convert str to upper case\ upper("example") -> EXAMPLE
ABBREV\bool = ABBREV(str, abbr, [len])\Test if abbr is an abbreviation of str
\with at least len characters\ abbrev("Program","Prog",4) -> 1\
abbrev("Process","Prog",4) -> 0\ abbrev("Process","Pro",4) -> 0
COMPARE\n = COMPARE(str1, str2, [pad])\
Determine position at which strings differ\
(0 if identical)\ compare("different","difference") -> 9
INDEX\n = INDEX(str,pat,[start])\Return position of pat in str, from 1 or\
start (0 if not found)\ index("Where in the world","e",6) -> 12\
index("Where in the world","w") -> 14\
index("Where in the world","W",2) -> 0\
Same as 'pos' except for the order of the arguments.
LASTPOS\n = LASTPOS(pat,str,[start])\Return position of pat in str, searching\
backwards from end or start\ lastpos("e","Where in the world") -> 12\
lastpos("e","Where in the world",10) -> 5
POS\n = POS(pat,str,[start])\Return position of pat in str,\
from 1 or start (0 if found)\ pos("e","Where in the world",6) -> 12\
pos("w","Where in the world") -> 14\
pos("W","Where in the world",2) -> 0\See also 'index'
VERIFY\n = VERIFY(str,list,[match],[start]) Search str\from 1
or start for characters in list; return index or 0\
Modes (match) : M - Return index of first list character of str\
Other/default - Return index of first non-list character\
verify("abracadabra","r","m",4) -> 10\ verify("abridgement","abcde") -> 3
CENTRE\s = CENTRE(str, width, [pad])\Center str in a field of given width\
centre("Middling",14) -> " Middling "\
center("Middling",16,"-") -> "----Middling----"
<4
LEFT\s = LEFT(str,count,[pad])\Extract leftmost count characters of str,\
pad on right if needed\ left("extraction",5) -> extra\
left("Total ",12,".") $20.00 -> "Total ...... $20.00
REVERSE\s = REVERSE(str)\Reverse str\ reverse("drawer") -> reward
RIGHT\s = RIGHT(str,width,[pad])\
Extract rightmost width characters of str,\pad on left if needed
right("extraction",6) -> action\ right("12345",6,"$") -> $12345
SPACE\s = SPACE(str, [len], [pad])\
Set word-breaks in str to len spaces (or pad)\
space("Space it out",3) -> Space it out\
space("| | | |",4,"-") -> |----|----|----|
DELWORD\s = DELWORD(str, start, [len])\
Delete len words from str, beginning at start word\
delword("Cut it out",2,1) -> Cut out
FIND\n = FIND(str, phrase)\Return position of word-string phrase in str\
find("Where in the world","in the") -> 2\
find("Where in the world","here") -> 0
SUBWORD\s = SUBWORD(str, start, [count])\
Extract count words (default=rest of str)\from str, from start word\
subword("Extract the third to fifth words",3,3)\
-> third to fifth
WORD\s = WORD(str,n)\Extract word n from str\
word("Extract the third word",3) -> third
WORDINDEX\n = WORDINDEX(str,n)\Determine character position in str\
of start of word n\ wordindex("Where in the world",4) -> 14
WORDLENGTH\n = WORDLENGTH(str,n)\Determine length of word n in str\
wordlength("How long is the targetted word?",5) -> 9
WORDS\n = WORDS(str)\Return number of words in str\
words("How many words are here?") -> 5
COPIES\s = COPIES(str, n)\Concatenate n copies of str\
copies("-",10) -> ----------\ copies("<*>",4) -> <*><*><*><*>
HASH\n = HASH(str)\Calculate a hash value for str\
hash('A') -> 65 hash('a') -> 97\
hash('AB') -> 131 hash('ab') -> 195\
hash("What is the point?") -> 122\
I never use HASH, probably because I don't understand\
how it might be of any use. It is one way of getting\
the ASCII value of a character, but ...
LENGTH\n = LENGTH(str)\Return length of str in characters\
length('antidisestablishmentarianism') -> 28
PARSE\PARSE [UPPER] source [template] [,template]\
Split input string(s) into substrings\
(Could do with a gadget column of its own.)\
Source name Source string contents\
ARG Arguments to present script or internal function\
EXTERNAL Input via STDERR file\
NUMERIC NUMERIC options: digits fuzz form\
PULL Input via STDIN file\
SOURCE type result called resolved ext host\
Info about how current script was called\
VALUE expr WITH Result of expression\
VAR varname Contents of varname\
VERSION version cpu mpu video freq\
Info about ARexx version and machine setup
XRANGE\s = XRANGE([c1],[c2])\Build character string from c1 to c2\
with consecutive ASCII values\ xrange("1","9") -> 123456789\
length(xrange("a","z")) -> 26
<5
ABS\absval = ABS(num)\Return absolute value of numeric expression\
abs(2) -> 2 abs(-1) -> 1
DIGITS\n = DIGITS()\Return current NUMERIC DIGITS setting\
Default : digits() -> 9\ Reset : numeric digits 3\
Check : digits() -> 3\
Use : x = 2 * 1.12345 -> 2.25
FORM\f = FORM()\Return current NUMERIC FORM setting\
Default : form() -> SCIENTIFIC\ Reset : numeric form engineering\
Check : form() -> ENGINEERING
FUZZ\f = FUZZ()\Return current NUMERIC FUZZ setting\
Used in making numeric comparisons\ Default : fuzz() -> 0\
Reset : numeric fuzz 2\ Check : fuzz() -> 2\
Cannot exceed one less than current numeric digits setting.
MAX\n = MAX(n1, n2 [, n3 ...])\Find the largest of a set of numbers\
max(1.1,10.2,100.5,1000.8) -> 1000.8
MIN\n = MIN(n1, n2 [, n3 ...])\Find the smallest of a set of numbers\
min(1.1,10.2,100.5,1000.8) -> 1.1
NUMERIC\NUMERIC DIGITS num\Set numeric calculation and display options\
NUMERIC FUZZ num\ NUMERIC FORM SCIENTIFIC\ NUMERIC FORM ENGINEERING\
See under DIGITS, FORM, and FUZZ
RANDOM\n = RANDOM([low],[high],[seed])\
Return pseudo-random integer between\low and high inclusive\
random() -> Any number from 0 to 999\
random(12,24) -> Any number from 12 to 24\
Seconds from 'time' makes a good seed :\ random(,,time('s'))
RANDU\n = RANDU([seed])\Return pseudo-random number between 0 and 1\
See also RANDOM
SIGN\n = SIGN(num)\Determine the sign of a number\
sign(-3) -> -1\ sign(0) -> 0\ sign(3) -> 1
TRUNC\n = TRUNC(number,[places])\Truncate number to places decimal places\
trunc(12.34567) -> 12\ trunc(12.34567,2) -> 12.34 (not rounded)
<6
Logical NOT ~\
if ~exists(filename) then say "Can't find file"\
The set of operators is listed in order of descending priority.\
Logical NOT is top of the list, only equalled in priority by\
unary plus and unary minus.
Unary and binary + and -\ Unary, with just one operand : balance = -100\
Unary + exists, but is rarely used.\
Binary : 2 + 3 = 5 ; 1.00099 - 0.00009 = 1.0009
Exponentiation ** ( = 'raised to the power of')\ 3 ** 3 = 27\
Multiplication *\ 3 * 3 = 9
Division\ Division / : 7 / 2 = 2.333\
Integer division % : 7 % 3 = 2\ Remainder // : 7 // 3 = 1\
Some languages use the terms DIV and MOD\for the second and third of\
these; e.g. 7 MOD 3 = 1
Concatenation ||\Use || to join strings together\with no intervening space.\
If you use a space you'll get a space.\ a = "Mega" ; b = "Disc" \
say a b a || b -> Mega Disc MegaDisc
Exact equality and exact inequality == ~==\
These are used less often than = and ~=,\but they can be useful.\
"Mega " == "Mega" -> 0 (NOT exactly equal)\
"Mega " = "Mega" -> 1 (Roughly equal)\
"Mega " ~== "Mega" -> 1 (Not exactly equal)
Equality and inequality = ~=\Rugged everyday workhorses, not fussy, for\
example, about leading or trailing spaces\
when they declare strings to be equal or not.\
"Disc" = "Disc " -> 1\ "Disc" = "Disk" -> 0
Greater than >\Greater than or equal to >=\
Not less than ~<\
The second and third of the trio are of course equivalent.\
Use whichever best expresses what you want to say.\
toffee_ready = (temperature >= boiling)
Less than <\Less than or equal to <= } These two\
Not more than ~> } are synonymous\See also > >= ~<
AND and OR\Logical AND & : if ready & willing then ...\
Inclusive OR | : if tired | cold | hungry then ...\
Any one of these is enough to prevent me working.\
Exclusive OR ^ or && :\
see_you_there = ( who_is_going_to_be_there = (Jane ^ Mary) )\
If they're BOTH going, then I'm not.\&& is an alternative to ^.
<7
BITAND\s = BITAND(str1, [str2], [pad])\
Return bit-wise AND of two strings, padded to equal length\
c2b(bitand('11110000'b,'10001111'b)) -> 10000000\
c2b(bitand('11110000'b)) -> 00100000\
I can't imagine any of the Bit functions being much use,\
but somebody might be interested, and I include them for\
the sake of attempted completeness.
BITCHG\s = BITCHG(str, n)\Invert bit n, counting from right, in str\
'Invert' means swap 0 and 1\
With i = 1 to 5, bitchg('A',i) yields C, E, I, Q, a\
bitchg('dog',21)" -> Dog\ reverse(bitchg('dog',5))" -> God
BITCLR\s = BITCLR(str, n)\Clear bit n, counting from right, in str\
'Clear' means set to 0\ bitclr('d',5) -> D\ bitclr('D',5) -> D
BITCOMP\n = BITCOMP(str1, str2, [pad])\Return first bit,\
counting from right,\at which str1 ~= str2 (-1 if equal)\
bitcomp('Dog','dog')" -> 21\ bitcomp('Dog','dig')" -> 9\
bitcomp('Dog','doe')" -> 1
BITOR\s = BITOR(str1, [str2], [pad])\
Return bit-wise OR of two strings,\padded to equal length\
bitor('ABCdef') -> abcdef\ bitor('Dog','doe') -> dog\
bitor('Dig','doe')" -> dog
BITSET\s = BITSET(str, n)\Set bit n, counting from right in str\
The opposite of BITCLR.\ bitset('d',5) -> d\ bitset('D',5) -> d
BITTST\bool = BITTST(str, n)\Test bit n, counting from right, in str\
bittst('A',6) -> 1 bittst('A',5) -> 0
BITXOR\s = BITXOR(str1, [str2], [pad])\
Return bit-wise exclusive-OR of two strings,\padded to equal length\
bitxor("ABCdef") -> abcDEF\ bitxor("A","1") -> p
<8
B2C\s = B2C(binstr)\Return character equivalent of binary string\
b2c("01011001 01100101 01110011") -> Yes
C2B\b = C2B(str)\Return binary digit string\equivalent to character string\
c2b("Yes")' -> 010110010110010101110011
C2D\n = C2D(str, [len])\
Return integer number corresponding\to string (of len bytes)\
c2d("A") -> 65\ c2d("AB",1) -> 66 (truncated to 'B')\
c2d("A"x) -> 10\ c2d("FF"x) -> 255\ c2d("Yes")' -> 5858675
C2X\h = C2X(str)\Return hexadecimal number\corresponding to string\
c2x("A") -> 41\ x2d(c2x("A")) -> 65
D2C\s = D2C(num,[count])\Return string equivalent,\
count bytes long, of num\ d2c(65) -> A\ d2c(5858675) -> Yes
D2X\h = D2X(num,[count])\Return hexadecimal string,\
count bytes long, equivalent to num\ d2x(65) -> 41\ d2x(16) -> 10
X2C\s = X2C(hex)\Return character equivalent of hex string\
x2c(41 42 43 44 61 62 63 64) -> ABCDabcd
X2D\n = X2D(hex,[n])\Convert n rightmost digits (or all)\
of hex string to decimal\ x2d(ff) -> 255\ x2d(0f) -> 15\
x2d(0f,1) -> -1
<9
DATATYPE : type = DATATYPE(str)\ bool = DATATYPE(str,mode)\
Test attributes of string (type = `NUM' or `CHAR')\
datatype(4) -> NUM datatype("Yes") -> CHAR\
If mode is specified, 1 or 0 is returned :\
Modes: A - Alphanumeric B - Binary L - Lower case\
M - Mixed case N - Numeric S - Symbol\
U - Upper case W - Whole number X - Hexadecimal\
datatype("YES",U) -> 1\ datatype("YES",L) -> 0\ datatype("Yes",M) -> 1
datatype(1.2,W) -> 0\ datatype(12,W) -> 1
DROP var [var ...]\Restore a variable to its uninitialized state\
say assigned ; ASSIGNED\ assigned = 3 ; say assigned ; 3\
drop assigned ; say assigned ; ASSIGNED
SYMBOL\s = SYMBOL(str)\Determine if a string is a valid ARexx symbol\
Returns LIT : a literal number or a valid but unused string\
VAR : a variable name to which a value has been attached\
or BAD : neither of the above
VALUE\val = VALUE(str)\Treating str as an ARexx symbol,\return its value\
It can, for example, handle user choices concisely:\
A_String = 24 ; B_String = 39 ; C_String = 55 ....\
pull type ; say value(type || "_String")\
If a user enters "A", the program will return "24"
<10
ECHO expr\Send the expression result\to the standard output\A synonym of 'say'.
LINES\n = LINES([file])\Return number of lines queued\for interactive stream
Works only with certain console handlers\such as Bill Hawes' ConMan, not\
with standard Amigas as purchased.
PULL [template] [,template ...]\Shorthand form of PARSE UPPER PULL\
parse upper pull a Input : John\ parse pull b John\
pull c John\
say a b c Output : JOHN John JOHN
PUSH expr\Pre-load the standard input\in `last-in, first-out' order\
Needs ConMan or AmigaDOS 2.0 +\Run this as an ARexx program :\
push 'list s:' ; push 'list libs:'\The 'libs:' listing will appear first.
QUEUE expr\Pre-load the standard input\in `first-in, first-out' order\
See the 'PUSH' entry.\Change 'push' to 'queue'\ and compare the order.
SAY [expr]\Send expression result to\standard output (usually console)\
rx 'say "If this program is run from CLI,\
this will appear in the CLI window."'
<11
CLOSE\bool = CLOSE(file)\Close the named file.
EOF\bool = EOF(file)\Return 1 if end of file\has been detected; else 0\
Examples : do until eof(myfile) ...\ if eof(myfile) then ...\
do while ~(eof(myfile)) ...
OPEN\bool = OPEN(file, name, [mode])\
Open a file called name in given mode\Modes: R - Read (default)\
W - Write (create)\ A - Append\
op = open(f,'MyFile',w) -> New file opened for writing\
op = open(f,'MyFile',r) -> Existing file opened for reading
READCH\s = READCH(file, [count])\Read count characters from file
READLN\s = READLN(file)\Read a line from file
SEEK\n = SEEK(file,offset,[mode])\
Move file position to offset according to mode\
Modes: C - Current (default) B - Beginning E - End\ n = seek(f)\
Will return current pointer position.\ n = seek(f,100)\
Pointer will move 100 bytes forward.\ n = seek(f,100,b)\
Pointer will move to 100 bytes from beginning of file.
WRITECH\n = WRITECH(file, str)\Write str to file, return count written\
n = writech(f,'entry')\ n -> 5
WRITELN\n = WRITELN(file, str)\
Write str plus linefeed to file,\return count written\
n = writeln(f,'entry')\ n -> 6 (5 chars + LF)
DELETE\bool = DELETE(name)\Delete a file or directory
EXISTS\bool = EXISTS(name)\Return True if given file or directory exists
MAKEDIR\bool = MAKEDIR(dirname)\Create a directory of the given name
RENAME\bool = RENAME(oldname, newname)\Rename a file or directory
SHOWDIR\filelist = SHOWDIR(dir, [mode], [pad])\
List the file and/or directory names in a directory\
Modes: A - All (default) F - Files only D - Directories only\
fl = showdir(c,f,'0a'x)\
Will list all files in 'c' directory in a single column,\
the linefeed character ('0a'x) being used as the pad.
STATEF\filestring = STATEF(pathname)\
Obtain information about a file or directory\
Format: type size blk bits day min tick com\ type -> FILE or DIR\
size -> in bytes\ blk -> in blocks\ bits -> protection settings\
day -> creation date in days since 1/1/1988\
min -> creation time in minutes since midnight\
tick -> creation time in ticks within the minute\
com -> filenote, if any\This file (as I'm writing it) has just returned\
FILE 22041 44 ----RWED 6085 526 2429
<12
DATE\d = DATE([outmode],[indate],[inmode])\
Find today's date, or info about a specified date\
Modes:\ B - Base (days since 01/01/0000)\ C - Century (days this century)\
D - Days (days since start of year, counting today)\
E - European (dd/mm/yy - e.g. 19/11/76)\
I - Internal (days since 01/01/1978)\
J - Julian (yyddd - 2-digit year, 3-digit days this year)\
M - Month name in English mixed case (e.g. `November')\
N - Normal, the default (dd mmm yyyy, e.g. 01 Jun 1986)\
O - Ordered (yy/mm/dd, e.g. 84/05/24)\
S - Standard (yyyymmdd, e.g. 19921005)\ U - USA (mm/dd/yy, 12/21/88)\
W - Weekday name in English mixed case (e.g. `Thursday')
ERRORTEXT : text = ERRORTEXT(n)\
Return a description of syntax error number n\
errortext(1) -> Program not found\ errortext(2) -> Execution halted\
errortext(3) -> Insufficient memory\Numbers go up to 48, with a few gaps.
OPTIONS Script options\ OPTIONS [NO] RESULTS Default is 'off'.\
Set it to 'on' if feedback required from another program.\
OPTIONS [NO] CACHE\
Default is 'on', for 'an internal statement-caching scheme'.\
OPTIONS PROMPT [expr]\ Set prompt strings to appear in PULL operations.\
OPTIONS FAILAT expr\ To specify a failure level for error reporting.
SOURCELINE: n = SOURCELINE()\ s = SOURCELINE(num)\
Read count of source lines, or\line num from current script.\
Much used in this program,\ to find each of these notes.
TIME\t = TIME([mode])\Find current or elapsed time\Modes:\
C - Civil (h:mmAM or h:mmPM, e.g. 3:07AM)\
E - Elapsed (s.cc, seconds and hundredths, in interval)\
H - Completed hours since midnight (e.g. 4)\
M - Completed minutes since midnight (e.g. 243)\
N - Normal, the default (hh:mm:ss, e.g. 17:04:41)\
R - Same as elapsed, but resets timer to 0.00\
S - Completed seconds since midnight (e.g. 17353)
TRACE mode\ TRACE [VALUE] expr\ TRACE num\Set tracing mode\
Modes: A - All clauses B - Background C - Commands\
E - Errors I - Intermediates L - Labels\
N - Normal O - Off R - Results\ S - Scan\
Special features:\ ? - Interactive +num - skip interactive pauses\
! - Command inhibition -num - trace suppression count
TRACE()\t = TRACE([mode])\
Get/set tracing mode (see modes under TRACE instruction)
<13
ADDLIB(name, pri, [offset, version])\
Add function library/host name to library list
ADDRESS\ ADDRESS name\ ADDRESS VALUE name-expression\
ADDRESS name command-expression\Modify host address; send command to a host\
Note format for sending an AmigaDOS command :\
Without quotes, and within an ARexx program,\
'address command ' any_AmigaDOS_command\will carry out any_AmigaDOS_command
ADDRESS()\host = ADDRESS()\Return host address string
FREESPACE : n = FREESPACE()\ n = FREESPACE(addr, size)\
Return size bytes of memory at addr\to ARexx's internal memory pool
GETCLIP\s = GETCLIP(clip)\Return value string associated with clip name\
See also SETCLIP
GETSPACE : addr = GETSPACE(size)\
Allocate size bytes of memory in\ARexx internal memory pool\
See also FREESPACE.\ I have never used either of them.
REMLIB\bool = REMLIB(name)\Remove an entry from the Library List,\
e.g. if memory is in short supply\and a library is no longer needed.
SETCLIP\bool = SETCLIP(name, [value])\Set string value for clip name\
(remove name if value omitted).\A good way to store strings (called 'clips')\
which need to be shared by programs or passed\between programs.
SHELL\ SHELL name\ SHELL VALUE name-expression\
SHELL name command-expression\Modify host address; send command to a host\
See also the ADDRESS instruction,\for which SHELL is an exact synonym.
SHOW\ s = SHOW(mode,,[pad]) Returns a list of names.\
bool = SHOW(mode,name) Returns 1 or 0.\Modes:\ C - Clips\ F - Files\
I - Internal ports\ L - Function Libraries\ P - Public ports
<14
CLOSEPORT : bool = CLOSEPORT(portname)\
Close a message port opened with OPENPORT
GETARG\arg = GETARG(packet, [whicharg])\
Obtain an argument string from a message packet
GETPKT\pkt = GETPKT(portname)\Pick up a message packet from a message port
OPENPORT\bool = OPENPORT(portname)\
Open a public message port with the given name\
See references to 'HO' within this program.
REPLY\1 = REPLY(pkt, [result], [result2])\
Return a message packet to its sender,\default results = 0, 0
TYPEPKT\cmd = TYPEPKT(pkt)\ count = TYPEPKT(pkt,'a')\
bool = TYPEPKT(pkt,mode)\Extract information from a message packet\
Modes: F - Function C - Command
WAITPKT\bool = WAITPKT(portname)\
Wait for a message packet to arrive at a port
<15
ALLOCMEM : mem = ALLOCMEM(size, [type])\
Allocate size bytes of system memory, with\
type attributes. You will rarely need to use this.
BADDR\addr = BADDR(bptr)\Convert BPTR to address\
'Rather esoteric'.\ Do you REALLY want to know?
DELAY\0 = DELAY(n)\Pause for n 50ths of a second
EXPORT\count = EXPORT(addr,[str],[len],[pad])\
Copy len bytes of str to memory at addr.\
'In practice ... rarely needed.... ARexx is\
unable to protect you from yourself when using\
this function.'(Zamara & Sullivan p.301)
FORBID\count = FORBID()\Turn off multitasking
FREEMEM\1 = FREEMEM(addr, size)\Free size bytes of memory at addr\
allocated by ALLOCMEM
IMPORT\s = IMPORT(addr,[len])\Return contents of len bytes\
(or 0-terminated) memory at addr\But see also EXPORT.
NEXT\value = NEXT(addr,[offset])\
Return the 4-byte value stored at addr + offset\
Handle with care.
NULL\'00000000'x = NULL()\
Return a 4-byte string corresponding\to a null address\
OFFSET\addr = OFFSET(addr,amount)\Return the address addr + amount, useful,\
for example, when locating fields within structures.
PERMIT\count = PERMIT()\Re-enable multitasking after FORBID
PRAGMA :\A collection of system-specific facilities\
Current directory oldcd = PRAGMA('d', [newcd])\
Task priority oldpri = PRAGMA('p', newpri)\
Stack size oldsize = PRAGMA('s', size)\
DOS requesters 1 = PRAGMA('w', [mode])\
Modes : 'n' = on, 'w' or none = off\
Task ID (address) id = PRAGMA('i')\
Console handler bool = PRAGMA('*', [file])
SHOWLIST : list = SHOWLIST(mode,,[pad])\
bool = SHOWLIST(mode, name)\ addr = SHOWLIST(mode, name,, 'a')\
Returns an astonishing amount of information, most of\
which you will never need, about a shared system list\Modes:\
A - Assigns D - Devices H - Handlers\
I - Interrupts L - Libraries M - Memory\
P - Ports R - Resources S - Semaphore\
T - Ready tasks V - Volumes W - Waiting tasks\
Note how the 2nd and 3rd arguments are never used together.
STORAGE\n = STORAGE()\ s = STORAGE(addr,[str],[len],[pad])\
Copy len bytes of str to memory at addr.\
Similar to EXPORT, but when used with no argument, returns\
the amount of free memory in the system.
*/